export default {
    namespaced: true,
    state: {
        //控制是否显示提示框
        isShow: false,
        //提示信息
        toastMsg: '默认提示内容...',
        //提示图标 (success成功，danger失败提示，warning警告)
        toastType: 'warning'
    },
    mutations: {
        //修改状态
        //payload:{isshow:'',msg:'',type:''}
        changeIsShowToast(state, payload) {
            state.isShow = payload.isshow;
            if (payload.isshow) {
                state.toastMsg = payload.msg;
                state.toastType = payload.type;
            }
        }
    },
    actions: {
        //异步
        asyncIsShowToast({
            commit
        }, payload) {
            //1. 调用mutations修改isshow，msg，type
            commit("changeIsShowToast", payload)
            //2. 增加定时器，2s后，调用mutations修改 修改isshow：false
            setTimeout(() => {
                commit("changeIsShowToast", {
                    isshow: false
                })
            }, 2000)
        }
    }
}